package com.shanyi.service.biz;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shanyi.dao.entity.TravelAddressDetailEntity;
import com.shanyi.dao.req.AddCountReqDto;
import com.shanyi.dao.req.TravelInfoListReqDto;
import com.shanyi.dao.req.TravelInfoReqDto;
import com.shanyi.dao.resp.TravelInfoListRespDto;
import com.shanyi.service.TravelService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author shanyi
 * @Date 2023/2/11 16:50
 */
@Service
public class TravelBiz {
    
    @Resource
    private TravelService travelService;
    
    public IPage<TravelInfoListRespDto> getTravelInfoList(TravelInfoListReqDto dto) {
        IPage<TravelAddressDetailEntity> iPage = travelService.getTravelInfoList(dto);

        return iPage.convert(u -> {
            TravelInfoListRespDto respDto = new TravelInfoListRespDto();
            BeanUtils.copyProperties(u,respDto);
            return respDto;
        });
    }

    public String addTravelInfo(TravelInfoReqDto dto) {
        // 进行插入操作
        return travelService.addTravelInfo(dto);
    }

    public String deleteTravelInfo() {
        return null;
    }

    public String updateTravelInfo() {
        return null;
    }

    public String addCount(AddCountReqDto dto) {
        return travelService.addCount(dto);
    }
}
